import os
import platform
import sys
import requests


# 8替代函数
def clean_replace(input_file, dict_replace):
    """
    :param input_file: 输入文件地址
    :param dict_replace: json格式的替换字典，
    :return: 数组格式输出数据
    """
    # 收取前端用户录入的替换字典
    # dict_replace = eval(dict_replace)

    with open(input_file) as file_obj:
        before = eval(file_obj.read())
        # 处理从txt文件获取的数据
        after = []
        for value in before:
            if value in dict_replace:
                after.append(dict_replace[value])
            else:
                after.append(value)

        return after


if __name__ == '__main__':
    print(clean_replace(sys.argv[1], eval(sys.argv[2])))
